$(function() {
	var raffle_1 = 1;
	var raffle_2 = 1;
	var raffle_3 = 1;
	$(document).ready(function() {
		$(".TheRecording").find(".RecordedContent").addClass("son animated zoomInLeft")
		setTimeout(function() {
			$(".TheRecording").find(".content").transit({
				x: 0
			}, 300)
			$(".footer").transit({
				y: 0
			}, 300)
		}, 600)
		$(".TheRecording").find(".GenerateaLoveLetter").addClass("son animated zoomInRight")
		$(".MusicFestival .logo1").addClass("son animated zoomInDown");
		$(".MusicFestival .logo3").addClass("son animated zoomInDown");
		$(".MusicFestival .logo4").addClass("son animated flipInY");
		$(".MusicFestival .logo5").addClass("son animated zoomInLeft");
		$(".MusicFestival .logo11").addClass("son animated zoomInRight");
		$(".MusicFestival .logo12").addClass("son animated zoomInLeft");
		setTimeout(function() {
			$(".PleaseEnterThe").addClass("son animated tada");
		}, 1000)
		$("#yanZ").on("click", function() {
			$(".PleaseEnterThe").removeClass("son animated tada");
		})
		setTimeout(function() {
			$(".MusicFestival .logo2").transit({
				x: 0
			}, 300);
			$(".MusicFestival .logo6").transit({
				x: 0
			}, 300);
			$(".MusicFestival .logo7").transit({
				x: 0
			}, 300);
			$(".MusicFestival .logo8").transit({
				x: 0
			}, 300);
			$(".MusicFestival .logo9").transit({
				y: 0
			}, 300);
			$(".MusicFestival .logo10").transit({
				y: 0
			}, 300);
		}, 800)
		setTimeout(function() {
			$(".MusicFestival .logo1").removeClass("son animated zoomInDown");
			$(".MusicFestival .logo3").removeClass("son animated zoomInDown");
			$(".MusicFestival .logo4").removeClass("son animated flipInY");
			$(".MusicFestival .logo5").removeClass("son animated zoomInLeft");
			$(".MusicFestival .logo11").removeClass("son animated zoomInRight");
			$(".MusicFestival .logo12").removeClass("son animated zoomInLeft");
			$(".MusicFestival .logo1").addClass("son animated headShake infinite");
			$(".MusicFestival .logo2").addClass("son animated bounce infinite");
			$(".MusicFestival .logo3").addClass("son animated wobble infinite");
			$(".MusicFestival .logo4").addClass("son animated swing infinite");
			$(".MusicFestival .logo5").addClass("son animated tada infinite");
			$(".MusicFestival .logo6").addClass("son animated fadeInUp infinite");
			$(".MusicFestival .logo7").addClass("son animated fadeInUp4 infinite");
			$(".MusicFestival .logo8").addClass("son animated fadeInUp5 infinite");
			$(".MusicFestival .logo9").addClass("son animated fadeInUp2 infinite");
			$(".MusicFestival .logo10").addClass("son animated fadeInUp3 infinite");
			$(".MusicFestival .logo11").addClass("son animated rotateIn infinite");
			$(".MusicFestival .logo12").addClass("son animated fadeInUp4 infinite");
		}, 1000)
	})
	//音乐
	var yiny = true;
	$("#musicImg").on("touchstart", function() {
		if(yiny) {
			$("#musicImg").css("animation-play-state", "paused");
			yiny = false;
		} else {
			$("#musicImg").css("animation-play-state", "inherit");
			yiny = true;
		}
	})
	$(".GenerateaLoveLetter").find(".qingS").one("click", function() {
		$(".GetTheSuccess2").css("display", "block");
		$(".GetTheSuccess2").transit({
			"opacity": "1"
		}, 300);
		$(".GetTheSuccess_gift_box2").transit({
			y: 0
		}, function() {
			setTimeout(function() {
				$(".GetTheSuccess_gift_box2").text("生成成功！！！");
				$(".GetTheSuccess2").one("click", function() {
					$(".GetTheSuccess_gift_box2").transit({
						y: "-200%",
						"opacity": "0"
					}, 300, function() {
						$(".GetTheSuccess2").transit({
							"opacity": "0"
						}, 300, function() {
							$(".GetTheSuccess2").css("display", "none");
						})
						$(".RecordedContent").transit({
							"scale": "0"
						}, 300, function() {
							$(".RecordedContent").css("display", "none")
						})
						$(".TheRecording").find(".content").transit({
							x: "-300%"
						}, 300, function() {
							$(".TheRecording").find(".content").css("display", "none")
						})
						$(".TheRecording").find(".GenerateaLoveLetter").transit({
							x: "300%"
						}, 300, function() {
							$(".TheRecording").find(".GenerateaLoveLetter").css("display", "none")
						})
						$(".TheRecording").find(".gaoB").css("display", "block");
						$(".TheRecording").find(".gaoB").addClass("son animated zoomInDown");
						$(".TheRecording").find(".faS").addClass("son animated zoomInRight");
						$(".TheRecording").find(".faS").css("display", "block");
					})
				})
			}, 1000)
		})
	})
	$(".TheRecording").find(".faS").one("click", function() {
		$(".TheRecording").find(".gaoB").removeClass("son animated zoomInDown");
		$(".TheRecording").find(".faS").removeClass("son animated zoomInRight");
		$(".TheRecording").find(".gaoB").transit({
			"scale": "0"
		}, 300, function() {
			$(".inputting").css("display", "block"),
				$(".confirm").css("display", "block")
		})
		$(".TheRecording").find(".faS").transit({
			x: "-500%"
		}, 300)
	});
	$(".Kais div").eq(0).one("click", function() {
		$(".Kais div").eq(0).find("span").css("display","block")
		$(".Kais div").eq(1).css("display", "block")
		$(".Kais div").eq(1).transit({
			y:0
		},160,function() {
			$(".Kais div").eq(1).addClass("son animated bounceOutUp")
			$(".Kais div").eq(0).removeClass("son animated flipInY")
		})
		$(".Kais div").eq(0).addClass("son animated flipInY")
		$(".Kais div").eq(0).find("img").attr("src", "img/zting.png")
		var b = 61;
		daoJs = setInterval(function() {
			$(".RecordedContent").find(".daoJs").text(b -= 1)
			if(b <= 0) {
				alert("时间到");
				clearInterval(daoJs);
			}
		}, 1000)
	})

	$(".Kais div").eq(1).one("click", function() {
		$(".Kais div").eq(0).find("span").css("display","none")
		$(".Kais div").eq(1).transit({
			"opacity": "1",
			"scale": "1"
		}, function() {
			$(".Kais div").eq(1).css("display", "none")
		})
		$(".Kais div").eq(0).addClass("son animated flipInY")
		$(".Kais div").eq(0).find("img").attr("src", "img/kaisly.png")
		clearInterval(daoJs);
	})
	$(".RecordedContent_bottom .content2").find(".keSr").one("click", function() {
		shurZf();
		$(".RecordedContent_bottom .content2").find("textarea").focus();
	})
	$(".RecordedContent_bottom .content2").find("textarea").one("click", function() {
		shurZf();
	})
	$(".Bf").find("span").one("click", function() {
		alert("功能暂未开放")
	})

	function shurZf() {
		$(".RecordedContent_bottom .content2").find(".keSr").transit({
			"scale": "0"
		}, function() {
			$(".RecordedContent_bottom .Bf").find(".keSr2").css("display", "block");
			$(".RecordedContent_bottom .Bf").find(".keSr2").transit({
				"scale": "1",
				"opacity": "1"
			}, 300)
		})
		var keSr2Cd = 140;
		$(".content2").find("textarea").on("input", function() {
			var textareaV = $(".content2").find("textarea").val().length;
			$(".Bf").find(".keSr2 i").text(keSr2Cd - textareaV);
			if(keSr2Cd - textareaV <= 0) {
				this.value = this.value.substring(1, keSr2Cd);
				return;
			}
		});
	}

	$(".confirm").on("click", function() {
		var arr = [12580, 5201314, 9494, 3838];
		var a;
		for(var i = 0; i < arr.length; i++) {
			if(arr[i] == $("#yanZ").val()) {
				a = i;
			}
		}
		$(".inputting").removeClass("son animated zoomInRight");
		$(".confirm").removeClass("son animated zoomInLeft");
		var yanZ = $("#yanZ").val();
		if(yanZ == "") {
			alert("验证码：不能为空");
		} else if(isNaN(yanZ)) {
			alert("请输入数字");
		} else if(yanZ == arr[a]) {
			$(".inputting").transit({
				scale: 0
			}, 300, function() {
				$(".inputting").css({
					"display": "none"
				})
				$(".raffle").css({
					"display": "block"
				})
				$(".raffle").transit({
					"scale": "1"
				})
			})
			$(".confirm").transit({
				x: "-300%",
			}, 200, function() {
				$(".confirm").css({
					"display": "none"
				})
				$(".PickUp").css({
					"display": "block"
				})
				$(".PickUp").transit({
					"display": "block",
					x: 0
				})
			})
		}
		$("#yanZ").val("");
		asd();
		asd1();
		asd2();
	})

	//抽奖
	var cJiang = true;
	$(".PickUp").one("click", function() {
		stop();
		if(cJiang) {
			choujiang3();
			choujiang2();
			choujiang1();
		} else {
			$(".raffle").transit({
				"scale": "0"
			}, 300)
			$(".PickUp").transit({
				"opacity": "0"
			}, 300, function() {
				$(".ThankYouForYourParticipation").css("display", "block")
				$(".ThankYouForYourParticipation_GetTheSuccess_gift_box").transit({
					y: 0,
					"opacity": "1"
				})
			})
		}
		setTimeout(function() {
			if(raffle_1 && raffle_2 && raffle_3 == 1) {
				$(".PickUp").css("display", "none");
				$(".PickUp2").css("display", "block");
				$(".PickUp2").text("领取奖品");
				$(".PickUp2").addClass("son animated bounceIn infinite");
				$(this).on("click", function() {
					$(".PickUp2").removeClass("son animated bounceIn infinite");
					$(".raffle").transit({
						"scale": "0"
					}, 200, function() {
						$(".raffle").css("display", "none");
						$(".jiangP").css("display", "block");
						$(".ConfirmToReceive").transit({
							x: 0
						}, function() {
							$(".ConfirmToReceive").addClass("son animated bounceIn infinite")
						})
					})
					$(".PickUp2").transit({
						x: "-200%"
					}, 200, function() {
						$(".PickUp2").css("display", "none");
					})
					$(".gift_box").addClass("son animated zoomInRight")
				})
			} else if(raffle_1 && raffle_2 && raffle_3 == 2) {
				$(".PickUp").text("中奖2")
			} else if(raffle_1 && raffle_2 && raffle_3 == 3) {
				$(".PickUp").text("中奖3")
			} else {
				$(".PickUp").text("未中奖")
			}
		}, 2400)
	})

	function asd() {
		var c1 = $(".raffle .img1").find("ul li").length
		var ab1 = $(".raffle .img1").find("ul li").length
		var liH1 = $(".raffle .img1").find("ul li").innerHeight();
		var liLength1 = $(".raffle .img1").find("ul li").length - c1;
		$(".raffle .img1").find("ul").css("transform", "translateY(-" + liH1 * (c1 - 1) + "px)");
		timer1 = setInterval(function() {
			c1--;
			c1 = c1 < liLength1 ? ab1 - 1 : c1;
			$(".raffle .img1").find("ul").css({
				"transform": "translateY(-" + (liH1 * c1) + "px)",
				"transition": "transform .1s"
			});
		}, 600)
	}

	function asd1() {
		var c2 = $(".raffle .img2").find("ul li").length
		var ab2 = $(".raffle .img2").find("ul li").length
		var liH2 = $(".raffle .img2").find("ul li").innerHeight();
		var liLength2 = $(".raffle .img3").find("ul li").length - c2;
		$(".raffle .img2").find("ul").css("transform", "translateY(-" + liH2 * (c2 - 1) + "px)");
		timer2 = setInterval(function() {
			c2--;
			c2 = c2 < liLength2 ? ab2 - 1 : c2;
			$(".raffle .img2").find("ul").css({
				"transform": "translateY(-" + (liH2 * c2) + "px)",
				"transition": "transform .1s"
			});
		}, 600)
	}

	function asd2() {
		var c3 = $(".raffle .img3").find("ul li").length
		var ab3 = $(".raffle .img3").find("ul li").length
		var liH3 = $(".raffle .img3").find("ul li").innerHeight();
		var liLength3 = $(".raffle .img3").find("ul li").length - c3;
		$(".raffle .img3").find("ul").css("transform", "translateY(-" + liH3 * (c3 - 1) + "px)");
		timer3 = setInterval(function() {
			c3--;
			c3 = c3 < liLength3 ? ab3 - 1 : c3;
			$(".raffle .img3").find("ul").css({
				"transform": "translateY(-" + (liH3 * c3) + "px)",
				"transition": "transform .1s"
			});
		}, 600)

	}

	function choujiang1() {
		$(".raffle .img1").find("ul li").eq(0).clone().appendTo("ul")
		var c1 = $(".raffle .img1").find("ul li").length
		var ab1 = $(".raffle .img1").find("ul li").length
		var liH1 = $(".raffle .img1").find("ul li").innerHeight();
		var liLength1 = $(".raffle .img1").find("ul li").length - c1;
		$(".raffle .img1").find("ul").css("transform", "translateY(-" + liH1 * (c1 - 1) + "px)");
		cj1 = setInterval(function() {
			c1--;
			c1 = c1 < liLength1 ? ab1 - 1 : c1;
			$(".raffle .img1").find("ul").css({
				"transform": "translateY(-" + (liH1 * c1) + "px)",
				"transition": "transform .1s"
			});
			setInterval(function() {
				if(c1 == raffle_1) {
					clearInterval(cj1);
				}
			}, 1300)
		}, 100)

	}

	function choujiang2() {
		$(".raffle .img2").find("ul li").eq(0).clone().appendTo("ul")
		var c2 = $(".raffle .img2").find("ul li").length
		var ab2 = $(".raffle .img2").find("ul li").length
		var liH2 = $(".raffle .img2").find("ul li").innerHeight();
		var liLength2 = $(".raffle .img3").find("ul li").length - c2;
		$(".raffle .img2").find("ul").css("transform", "translateY(-" + liH2 * (c2 - 1) + "px)");
		cj2 = setInterval(function() {
			c2--;
			c2 = c2 < liLength2 ? ab2 - 1 : c2;
			$(".raffle .img2").find("ul").css({
				"transform": "translateY(-" + (liH2 * c2) + "px)",
				"transition": "transform .1s"
			});
			setInterval(function() {
				if(c2 == raffle_2) {
					clearInterval(cj2);
				}
			}, 1600)
		}, 100)

	}

	function choujiang3() {
		$(".raffle .img3").find("ul li").eq(0).clone().appendTo("ul")
		var c3 = $(".raffle .img3").find("ul li").length
		var ab3 = $(".raffle .img3").find("ul li").length
		var liH3 = $(".raffle .img3").find("ul li").innerHeight();
		var liLength3 = $(".raffle .img3").find("ul li").length - c3;
		$(".raffle .img3").find("ul").css("transform", "translateY(-" + liH3 * (c3 - 1) + "px)");
		cj3 = setInterval(function() {
			c3--;
			c3 = c3 < liLength3 ? ab3 - 1 : c3;
			$(".raffle .img3").find("ul").css({
				"transform": "translateY(-" + (liH3 * c3) + "px)",
				"transition": "transform .1s"
			});
			setInterval(function() {
				if(c3 == raffle_3) {
					clearInterval(cj3);
				}
				cJiang = false;
			}, 2000)
		}, 100)

	}

	function stop() {
		clearInterval(timer1);
		clearInterval(timer2);
		clearInterval(timer3);
	}

	$(".ConfirmToReceive").one("click", function() {
		$(".GetTheSuccess").css("display", "block");
		$(".GetTheSuccess").transit({
			"opacity": "1"
		}, 1000);
		$(".GetTheSuccess_gift_box").transit({
			y: 0
		}, 300);
	})
	$(".GetTheSuccess").on("click", function() {
		$(".GetTheSuccess").transit({
			"opacity": "0"
		}, 1000);
		$(".GetTheSuccess_gift_box").transit({
				y: "-200%"
			}, 300),
			function() {
				$(".GetTheSuccess").css("display", "none");
			};
	})
	document.addEventListener("DOMContentLoaded", function() {
		document,
		body.style.height = window.innerHeight + "px"
	}, false);
})